// 夜间模式切换脚本
(function() {
  const btn = document.getElementById('nightModeToggle');
  const icon = document.getElementById('nightModeIcon');
  const moonPath = document.getElementById('moonPath');
  const body = document.body;

  // 太阳图标路径
  const sunPath = 'M14 8a6 6 0 1 1 0 12a6 6 0 0 1 0-12zm0-4v4m0 12v4m8-8h-4m-8 0H2m16.97-6.97l-2.83 2.83m-8.28 8.28l-2.83 2.83m14.14 0l-2.83-2.83m-8.28-8.28l-2.83-2.83';
  // 月亮图标路径
  const moonPathD = 'M18 14a6 6 0 0 1-6 6A6 6 0 0 0 18 14z';

  function setNightMode(on) {
    if (on) {
      body.classList.add('night-mode');
      moonPath.setAttribute('d', sunPath);
      moonPath.setAttribute('fill', '#c23b23');
    } else {
      body.classList.remove('night-mode');
      moonPath.setAttribute('d', moonPathD);
      moonPath.setAttribute('fill', '#b0a084');
    }
    localStorage.setItem('nightMode', on ? '1' : '0');
  }

  // 初始化
  const saved = localStorage.getItem('nightMode');
  setNightMode(saved === '1');

  btn.addEventListener('click', function() {
    const isNight = !body.classList.contains('night-mode');
    setNightMode(isNight);
  });
})(); 